package com.study.lihan;
/*
* 自定义子线程处理器
* */

public class TestExcetionHandler implements  Runnable{
    private volatile Integer num = 1;
    public static void main(String[] args) {
        Thread t = new Thread(new TestExcetionHandler());
        t.setName("1号线程");
        t.setUncaughtExceptionHandler(new MyUnchecckedExceptionhandler());
        t.start();
    }
    @Override
    public void run() {
        while (true){
            System.out.println(num);
            if(num == 5){
                throw new MyException("抛出异常了");
            }
            num++;
        }
    }
}
